{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="user_name" class="layui-input search" name="user_name" value="" placeholder="联赛名字|主队|客队|赛事ID"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <select name="mf_state">
                                <option value="">不限状态</option>
                                <option value="1">未开始</option>
                                <option value="2">进行中</option>
                                <option value="3">完场</option>
                                <option value="4">异常结束</option>
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <select name="mf_fid">
                                <option value="">不限足球篮球</option>
                                <option value="1">足球</option>
                                <option value="2">篮球</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--图片显示模板-->
                    <!--操作模板-->
                    <script type="text/html" id="mf_fid">
                    {{# if(d.mf_fid == 1){ }}
                    足球
                    {{# } }}
                    {{# if(d.mf_fid == 2){ }}
                    篮球
                    {{# } }}
                    </script>

                    <script type="text/html" id="mf_state">
                    {{# if(d.mf_state == 0){ }}
                    未开始
                    {{# } }}
                    {{# if(d.mf_state > 0){ }}
                    进行中
                    {{# } }}
                    {{# if(d.mf_state == -1){ }}
                    完场
                    {{# } }}
                    {{# if(d.mf_state < -1){ }}
                    异常结束
                    {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('详情', '{:url('matchInfo')}?mf_id={{d.mf_id}}')" class="btn btn-primary btn-xs m-r-xs" title="详情">详情</a>
                        <a href="javascript:;" onclick="wk.layer_show('用户讨论', '{:url('talks')}?mf_fj_matchid={{d.mf_fj_matchid}}')" class="btn btn-primary btn-xs m-r-xs" title="用户讨论">用户讨论</a>
                        <a href="javascript:;" onclick="wk.layer_show('文字直播', '{:url('lives')}?mf_fj_matchid={{d.mf_fj_matchid}}')" class="btn btn-primary btn-xs m-r-xs" title="文字直播">文字直播</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Match/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
//                {type: 'checkbox', fixed: 'left'}
                  {type:'numbers', width: 70, title: '序号'}
                , {field: 'mf_fid', width: 90, title: '赛事类型', align: 'center',templet: '#mf_fid'}
                , {field: 'mf_name', width: '110', title: '联赛名字', align: 'center'}
                , {field: 'mf_home_name_cn', width: '', title: '主队', align: 'center'}
                , {field: 'mf_away_name_cn', width: '', title: '客队', align: 'center'}
                , {field: 'mf_match_time', width: '100', title: '比赛时间', align: 'center'}
                , {field: 'mf_fj_matchid', width: '90', title: '赛事id', align: 'center'}
                , {field: 'mf_views', width: '100', title: '浏览数', sort: true,align: 'center'}
                , {field: 'mf_state', width: '100', title: '状态', align: 'center',templet: '#mf_state'}
                , {fixed: 'right', width:220, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.aaasss').viewer({
                    url: 'data-original'
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAllNoSelect($('#allidsForOut').val(),$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>